'use strict';

var _mm = require('util/mm.js')

var userService = {
	// 用户注册
	register: function(userInfo, resolve, reject) {
		_mm.request({
			url: _mm.getServerUrl('/user/register.do'),
			data: userInfo,
			method: 'POST',
			success: resolve,
			error: reject
		})
	},

	// 用户名验证
	checkUsername: function(username, resolve, reject) {
		_mm.request({
			url : _mm.getServerUrl('/user/check_valid.do?act111=check&type111=test'),	// '/user/check_valid.do'
			data: {
				type: 'username',
				str: username
			},
			method: 'POST',
			success: resolve,
			error: reject
		});
		
	},
	// 用户登录
	login: function(userInfo, resolve, reject) {
		_mm.request({
			url: _mm.getServerUrl('/user/login.do'),
			data: userInfo,
			method: 'POST',
			success: resolve,
			error: reject
		});
	},
	// 检查登录状态
	checkLogin: function(resolve, reject) {
		_mm.request({
			url: _mm.getServerUrl('/user/get_user_info.do'),
			method: "POST",
			success: resolve,
			error: reject
		})
	},
	// 获取密码重置问题
	getQuestion: function(username, resolve, reject) {
		console.log('获取密码重置问题');
		
	},
	// 检查密码提示问题答案
	checkAnswer: function(userInfo, resolve, reject) {
		console.log('检查密码提示问题答案');
		
	},
	// 重置密码
	resetPassword: function(userInfo, resolve, reject) {
		console.log('重置密码');
	},
	// 获取用户信息
	getUserInfo: function(resolve, reject) {
		console.log('获取用户信息');
		var userInfo = {
			username: 'liuayong',
			phone: '13718526927',
			email: '404842799@qq.com',
			question: '我是谁?',
			answer: '努力的南小北',
		}

		resolve(userInfo)

		
	},
	// 更新用户信息
	updateUserInfo: function(userInfo, resolve, reject) {
		console.log('更新用户信息');
		
	},
	// 登入状态跟新密码
	updateUserPass: function(userInfo, resolve, reject) {
		console.log('登入状态跟新密码');
		
	},
	// 退出登录
	logout: function(resolve, reject) {
		console.log('退出登录');
		
	},
}


module.exports = userService ;
